<template>
  <view class="header-bar">
    <view v-if="showBack" class="back-btn" @click="handleBack">
      <uni-icons type="arrowleft" size="24" color="#64b5f6"></uni-icons>
    </view>
    <text class="title">{{ title }}</text>
  </view>
</template>

<script>
export default {
  props: {
    title: {
      type: String,
      required: true
    },
    showBack: {
      type: Boolean,
      default: false
    }
  },
  methods: {
    handleBack() {
      uni.navigateBack({
        delta: 1
      });
    }
  }
};
</script>

<style scoped lang="scss">
.header-bar {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: calc(8px + env(safe-area-inset-top)) 12px 8px 12px;
  background: var(--system-background);
  border-bottom: 1px solid var(--separator);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
}

.title {
  font-size: 18px;
  font-weight: 600;
  color: var(--label-primary);
  margin: 0;
  letter-spacing: 0.5px;
  text-shadow: 0 1px 1px rgba(255, 255, 255, 0.6);
  animation: fadeIn 0.8s ease-in;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  line-height: 1.2;
}

@media (min-width: 768px) {
  .header-bar {
    padding: calc(24px + env(safe-area-inset-top)) 24px 16px 24px;
  }
  
  .title {
    font-size: 24px;
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
